<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/



Route::get('/', function () {
    return view('index');
});

function rq($key=null,$default=null)
{
  if(!$key) return Request::all();
  return Request::get($key,$default);
}

function user_ins()
{

  return new App\Http\Models\User;
}

 function  question_ins()
{
 return new App\Http\Models\Question;
}

function  answer_ins()
{
return new App\Http\Models\Answer;
}

function  comment_ins()
{
return new App\Http\Models\Comment;
}


Route::get('api',function ()
{
  return ['version'=>1.0];
});

Route::any('api/user',function(){


    return user_ins()->signup();

});

Route::any('api/login',function(){

    return  user_ins()->login();

});


Route::any('api/logout',function(){


    return user_ins()->logout();

});

Route::any('test',function(){


    return user_ins()->is_logged_in();
});

Route::any('api/question/add', function(){

  return question_ins()->add();

});

Route::any('api/question/change', function(){

  return question_ins()->change();

});

Route::any('api/question/read', function(){

  return question_ins()->read();

});



Route::any('api/question/remove', function(){

  return question_ins()->remove();

});


Route::any('api/answer/add', function(){

  return answer_ins()->add();

});



Route::any('api/answer/change', function(){

  return answer_ins()->change();

});

Route::any('api/answer/read', function(){

  return answer_ins()->read();

});

Route::any('api/answer/vote', function(){

  return answer_ins()->vote();;

});

Route::any('api/timeline', 'CommonController@timeline');





Route::any('api/comment/add', function(){

  return comment_ins()->add();

});


Route::any('api/comment/read', function(){

  return comment_ins()->read();

});

Route::any('api/comment/remove', function(){

  return comment_ins()->remove();

});
